Skip to content

Conversation

@ladaapp
Copy link

@ladaapp ladaapp commented Jan 12, 2026

Was trying to use QSV encoders but noticed that the property they use for quality-based mode is unavailable. This PR exposes it in PyAV.

Couldn't think of a useful test for this as QSV wouldn't be available in CI and i'm not aware of another video encoder that uses this (tested with libx264 but it's ignored).

Reference:

Example

import av
import av.datasets

input_container = av.open(av.datasets.curated("pexels/time-lapse-video-of-night-sky-857195.mp4"))
output_container = av.open("hevc_qsv_encoded.mp4", "w", options={})

input_stream = input_container.streams.video[0]
output_stream = output_container.add_stream('hevc_qsv', input_stream.average_rate)
output_stream.width = input_stream.width
output_stream.height = input_stream.height

output_stream.pix_fmt = "nv12"
output_stream.codec_context.global_quality = 20
output_stream.codec_context.qscale = True

for frame in input_container.decode(video=0):
    packet = output_stream.encode(frame)
    if packet: output_container.mux(packet)

input_container.close()
output_container.close()

@ladaapp
Copy link
Author

ladaapp commented Jan 16, 2026

Looks like this change is not needed and setting it like it's done for other video encoders does actually work (via Output Stream options dict)

output_stream.options = {"global_quality": "40"}

ffmpeg -h encoder=hevc_qsv doesn't mention it as an option but it still seems to work just fine.

@WyattBlue Feel free to close this MR if you think there is no need for it

@WyattBlue WyattBlue closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants